/***
 * 
 *  Title:BaseUIForm
 *  
 *  
 *  Description:
 *         功能：定义所有UI窗体的父类
 *         定义四个生命周期：
 *         1.Display 显示状态
 *         2.Hiding 隐藏状态
 *         3.ReDisplay 在显示状态
 *         4.Freeze 冻结状态
 *         
*  Author:jack
*
*  Data:2023-12-28
 *  
 *  Modify:
 *  
 *  
 *  
 */

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class BaseUIForm : MonoBehaviour
{
    //窗体类型
    private UIType _CurrentUIType = new UIType();

    public UIType CurrentUIType { get => _CurrentUIType; set => _CurrentUIType = value; }

    #region 窗体的四种状态
    /// <summary>
    /// 显示状态
    /// </summary>
    public virtual void Display()
    {
        this.gameObject.SetActive(true);
        //设置模态窗体调用（必须是弹出窗体）
        if (_CurrentUIType.UIForms_Type == UIFormType.PopUp)
        {
            UIMaskMgr.GetInstance().setMaskWindow(this.gameObject, _CurrentUIType.UIForms_LucencyType);
        }

    }
    /// <summary>
    /// 隐藏状态
    /// </summary>
    public virtual void Hide()
    {
        this.gameObject.SetActive(false);
        //设置模态窗体调用（必须是弹出窗体）
        if (_CurrentUIType.UIForms_Type == UIFormType.PopUp)
        {
            UIMaskMgr.GetInstance().CancelMaskWindow();
        }
    }
    /// <summary>
    /// 重新显示状态
    /// </summary>
    public virtual void Redisplay()
    {
        this.gameObject.SetActive(true);
        //设置模态窗体调用（必须是弹出窗体）
        if (_CurrentUIType.UIForms_Type == UIFormType.PopUp)
        {
            UIMaskMgr.GetInstance().setMaskWindow(this.gameObject, _CurrentUIType.UIForms_LucencyType);
        }
    }
    /// <summary>
    /// 冻结状态
    /// </summary>
    public virtual void Freeze()
    {
        this.gameObject.SetActive(true);
    }
    #endregion

    #region 封装子类常用方法
    /// <summary>
    /// 注册按钮事件
    /// </summary>
    /// <param name="buttonName">按钮节点名称</param>
    /// <param name="delHandle">委托需要注册的方法</param>
    protected void RigisterButtonObjectEvent()
    {

    }
    /// <summary>
    /// 打开UI窗体
    /// </summary>
    /// <param name="uiFormName"></param>
    protected void OpenUIForm(string uiFormName)
    {
        UIManager.GetInstance().ShowUIForms(uiFormName);
    }
    /// <summary>
    /// 关闭本UI窗体
    /// </summary>
    protected void CloseUIForm()
    {
        string strUIFromName = string.Empty;                       //处理后的UIFrom名称

        strUIFromName = gameObject.name;

        UIManager.GetInstance().CloseUIForms(strUIFromName);
    }
    #endregion

}
